<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>怡臣 | 店铺管理</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/Public/admin/adminlte/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="/Public/admin/adminlte/plugins/font-awesome/font-awesome.min.css">
    <!-- Ionicons -->
    <!--link rel="stylesheet" href="/Public/admin/adminlte/plugins/ionicons/ionicons.min.css"-->
    <!-- Theme style -->
    <link rel="stylesheet" href="/Public/admin/adminlte/dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="/Public/admin/adminlte/dist/css/skins/_all-skins.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="/Public/admin/adminlte/plugins/iCheck/flat/blue.css">
    <!-- Morris chart -->
    <link rel="stylesheet" href="/Public/admin/adminlte/plugins/morris/morris.css">
    <!-- jvectormap -->
    <link rel="stylesheet" href="/Public/admin/adminlte/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
    <!-- Date Picker -->
    <link rel="stylesheet" href="/Public/admin/adminlte/plugins/datepicker/datepicker3.css">
    <!-- Daterange picker -->
    <link rel="stylesheet" href="/Public/admin/adminlte/plugins/daterangepicker/daterangepicker.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="/Public/admin/adminlte/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <!-- common css -->
    <link rel="stylesheet" href="/Public/admin/css/common.css">
    <!-- jQuery 2.2.3 -->
    <script src="/Public/admin/adminlte/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <!-- jQuery UI 1.11.4 -->
    <script src="/Public/admin/adminlte/bootstrap/js/jquery-ui.min.js"></script>
    <script src="/Public/admin/js/jquery.validate.min.js"></script>
    <script src="/Public/admin/js/jquery.validate.config.js"></script>
    <script src="/Public/admin/js/common.js?v=20170317001"></script>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="/Public/admin/adminlte/plugins/html5shiv/html5shiv.min.js"></script>
    <script src="/Public/admin/adminlte/plugins/html5shiv/respond.min.js"></script>
    <![endif]-->
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <header class="main-header">
        <!-- Logo -->
        <a href="" class="logo">
            <span class="logo-mini"><b>怡臣</b></span>
            <span class="logo-lg"><b>怡臣店铺</b>管理</span>
        </a>
        <nav class="navbar navbar-static-top">
            <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
            </a>
            <div class="navbar-custom-menu">
                <ul class="nav navbar-nav">
                    <li class="dropdown notifications-menu">
                        <a href="/Public/download/images.zip" class="dropdown-toggle">
                            <span class="hidden-xs">图片包下载</span>
                        </a>
                    </li>
                    <li class="dropdown user user-menu">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                            <img src="/Public/admin/adminlte/dist/img/store-face.png" class="user-image"
                                 alt="User Image">
                            <span class="hidden-xs"><?php echo session('userInfo')['username']?></span>
                        </a>
                    </li>
                    <li class="dropdown notifications-menu">
                        <a href="<?php echo U('admin/login/loginOut');?>" class="dropdown-toggle">
                            <i class="fa fa-bell-o">退出</i>
                            <span class="label label-warning">~</span>
                        </a>
                    </li>
                    <li class="dropdown notifications-menu">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
                            <i class="fa fa-bell-o">订单消息</i>
                            <span class="label label-warning order_msg"></span>
                        </a>
                        <ul class="dropdown-menu">
                            <!--<li class="header">清空全部</li>-->
                            <li>
                                <div class="slimScrollDiv" style="position: relative; overflow: hidden; width: auto; height: 200px;">
                                    <ul class="menu order-ul-msg" style="width: 100%; height: 200px;">

                                    </ul>
                                    <div class="slimScrollBar" style="background: rgb(0, 0, 0); width: 3px; position: absolute; top: 0px; opacity: 0.4; display: none; border-radius: 7px; z-index: 99; right: 1px; height: 195.122px;"></div>
                                    <div class="slimScrollRail" style="width: 3px; height: 100%; position: absolute; top: 0px; display: none; border-radius: 7px; background: rgb(51, 51, 51); opacity: 0.2; z-index: 90; right: 1px;"></div>
                                </div>
                            </li>
                            <li class="footer"><a href="<?php echo U('admin/Orders/orderList');?>">查看全部订单</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </nav>
    </header>

<!-- Left logo -->
<?php
if (session('userInfo')['type'] == 1) { ?>
<aside class="main-sidebar">
    <section class="sidebar">
        <!-- 导航页面 -->
        <ul class="sidebar-menu">


            <li class="<?php echo CONTROLLER_NAME == 'Index' ? 'active' : ''; ?> treeview">
                <a href="<?php echo U('Admin/index/index');?>">
                    <i class="fa fa-dashboard"></i> <span>后台首页</span>
                </a>
            </li>

            <li class="treeview <?php echo CONTROLLER_NAME == 'Purchase' ? 'active' : ''; ?>">
                <a href="javascript:;">
                    <i class="fa fa-th"></i> <span>采购</span>
                    <span class="pull-right-container">
                        <i class="fa fa-angle-left pull-right"></i>
                    </span>
                </a>
                <ul class="treeview-menu">
                    <li class="<?php if(ACTION_NAME == index): ?>active<?php endif; ?>"><a href="<?php echo U('Purchase/index');?>"><i class="fa fa-circle-o"></i> 采购商品列表</a></li>
                    <li class="<?php if(ACTION_NAME == shoppingCart): ?>active<?php endif; ?>"><a href="<?php echo U('Purchase/shoppingCart');?>"><i class="fa fa-circle-o"></i> 我的采购计划</a></li>
                    <li class="<?php if(ACTION_NAME == shoppingList): ?>active<?php endif; ?>"><a href="<?php echo U('Purchase/shoppingList');?>"><i class="fa fa-circle-o"></i> 我的采购单</a></li>
                </ul>
            </li>
            <li class="<?php echo CONTROLLER_NAME == 'Page' || CONTROLLER_NAME == 'ShortcutMenu' || CONTROLLER_NAME == 'Carousel' || CONTROLLER_NAME == 'Search' ? 'active' : ''; ?>">
                <a href="javascript:;">
                    <i class="fa fa-th"></i> <span>首页管理</span>
                    <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                </a>
                <ul class="treeview-menu">
                    <li><a href="/Admin/carousel/index"><i class="fa fa-circle-o"></i> 轮播图管理</a></li>
                    <li><a href="/Admin/ShortcutMenu/index"><i class="fa fa-circle-o"></i> 图标栏目管理</a></li>
                    <li><a href="/Admin/Page/index"><i class="fa fa-circle-o"></i> 首页促销</a></li>
                    <li><a href="/Admin/Page/recommend"><i class="fa fa-circle-o"></i> 商品推荐</a></li>
                    <li><a href="<?php echo U('Search/index');?>"><i class="fa fa-circle-o"></i> 搜索关键字</a></li>
                    <li><a href="<?php echo U('Artice/index');?>"><i class="fa fa-circle-o"></i> 文章管理</a></li>
                </ul>
            </li>
            <li class="<?php if(CONTROLLER_NAME == Weixin or CONTROLLER_NAME == Poster): ?>active<?php endif; ?>">
                <a href="javascript:;">
                    <i class="fa fa-th"></i> <span>微信设置</span>
                    <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                </a>
                <ul class="treeview-menu">
                    <li class="<?php if(CONTROLLER_NAME == index): ?>active<?php endif; ?>"><a href="/Admin/Weixin/index"><i class="fa fa-circle-o"></i> 微信消息模板</a></li>
                </ul>
            </li>
            <li class="<?php echo CONTROLLER_NAME == 'Letter' ? 'active' : ''; ?>">
                <a href="javascript:;">
                    <i class="fa fa-th"></i> <span>短信设置</span>
                    <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                </a>
                <ul class="treeview-menu">
                    <li class="<?php if(CONTROLLER_NAME == index): ?>active<?php endif; ?>"><a href="/Admin/Letter/index"><i class="fa fa-circle-o"></i> 短信模板</a></li>
                </ul>
            </li>
            <li class="treeview <?php echo CONTROLLER_NAME == 'Label' || CONTROLLER_NAME == 'StoreGoods' || CONTROLLER_NAME == 'StoreCat' || CONTROLLER_NAME == 'StoreDot' || CONTROLLER_NAME == 'Store' ? 'active' : ''; ?>">
                <a href="javascript:;">
                    <i class="fa fa-laptop"></i>
                    <span>商品管理</span>
                    <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                </a>
                <ul class="treeview-menu">
                    <li><a href="<?php echo U('/Admin/StoreCat/index');?>"><i class="fa fa-circle-o"></i> 商品分类</a></li>
                    <li><a href="<?php echo U('/Admin/StoreGoods/index');?>"><i class="fa fa-circle-o"></i> 商品配置</a></li>
                    <li><a href="<?php echo U('/Admin/StoreGoods/putaway');?>"><i class="fa fa-circle-o"></i> 上架商品管理</a></li>
                    <li><a href="<?php echo U('/Admin/Label/index');?>"><i class="fa fa-circle-o"></i> 商品标签</a></li>
                </ul>
            </li>
            <li class="treeview <?php echo CONTROLLER_NAME == 'Rbac' ? 'active' : ''; ?>">
                <a href="javascript:;">
                    <i class="fa fa-edit"></i> <span>权限设置</span>
                    <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                </a>
                <ul class="treeview-menu">
                    <li><a href="<?php echo U('Admin/Rbac/user');?>"><i class="fa fa-circle-o"></i> 账号</a></li>
                    <li><a href="<?php echo U('Admin/Rbac/role');?>"><i class="fa fa-circle-o"></i> 角色</a></li>
                    <li><a href="<?php echo U('Admin/Rbac/menu');?>"><i class="fa fa-circle-o"></i> 菜单</a></li>
                </ul>
            </li>
            <li class="treeview <?php if(CONTROLLER_NAME == Orders or CONTROLLER_NAME == QgsOrders): ?>active<?php endif; ?>">
                <a href="javascript:;">
                    <i class="fa fa-table"></i> <span>订单</span>
                    <span class="pull-right-container">
                      <i class="fa fa-angle-left pull-right"></i>
                    </span>
                </a>
                <ul class="treeview-menu">
                    <li><a href="<?php echo U('Orders/orderList');?>"><i class="fa fa-circle-o"></i> 订单列表</a></li>
                    <li><a href="<?php echo U('QgsOrders/orderList');?>"><i class="fa fa-circle-o"></i> 全国送会员订单</a></li>
                </ul>
            </li>

            <li class="treeview <?php if(CONTROLLER_NAME == Giftcode or CONTROLLER_NAME == OrderPromotion or CONTROLLER_NAME == Promotion or CONTROLLER_NAME == DiscountCoupon or CONTROLLER_NAME == Flashsales): ?>active<?php endif; ?>">
                <a href="javascript:;">
                    <i class="fa fa-envelope"></i> <span>营销</span>
                    <span class="pull-right-container">
                        <i class="fa fa-angle-left pull-right"></i>
                    </span>
                </a> 
                <ul class="treeview-menu">
                    <li class="<?php if(CONTROLLER_NAME == DiscountCoupon): ?>active<?php endif; ?>"><a href="<?php echo U('DiscountCoupon/index');?>"><i class="fa fa-circle-o"></i> 优惠券</a></li>
                    <li class="<?php if(CONTROLLER_NAME == GoodsPromotion): ?>active<?php endif; ?>"><a href="<?php echo U('GoodsPromotion/index');?>"><i class="fa fa-circle-o"></i> 商品促销</a></li>
                    <li class="<?php if(CONTROLLER_NAME == OrderPromotion): ?>active<?php endif; ?>"><a href="<?php echo U('OrderPromotion/index');?>"><i class="fa fa-circle-o"></i> 订单促销</a></li>
                    <li class="<?php if(ACTION_NAME == group): ?>active<?php endif; ?>"><a href="<?php echo U('Promotion/group');?>"><i class="fa fa-circle-o"></i> 组合促销</a></li>
                    <li class="<?php if(CONTROLLER_NAME == Flashsales): ?>active<?php endif; ?>"><a href="<?php echo U('Flashsales/index');?>"><i class="fa fa-circle-o"></i> 限时抢购</a></li>
                    <li class="<?php if(CONTROLLER_NAME == Giftcode): ?>active<?php endif; ?>"><a href="<?php echo U('Giftcode/index');?>"><i class="fa fa-circle-o"></i> 领券中心</a></li>
                    <!--<li><a href="pages/tables/simple.html"><i class="fa fa-circle-o"></i> 商品发现</a></li>-->
                </ul>                
            </li>
            <li class="treeview <?php if(CONTROLLER_NAME == Special): ?>active<?php endif; ?>">
                <a href="javascript:;">
                    <i class="fa fa-envelope"></i> <span>活动专题</span>
                    <span class="pull-right-container">
                        <i class="fa fa-angle-left pull-right"></i>
                    </span>
                </a> 
                <ul class="treeview-menu">
                    <li class="<?php if(ACTION_NAME == index or ACTION_NAME == template): ?>active<?php endif; ?>"><a href="<?php echo U('special/index');?>"><i class="fa fa-circle-o"></i> 专题列表</a></li>
                    <li class="<?php if(ACTION_NAME == index or ACTION_NAME == template): ?>active<?php endif; ?>"><a href="<?php echo U('special/advert');?>"><i class="fa fa-circle-o"></i> 专题广告</a></li>
                    <li class="<?php if(ACTION_NAME == cart): ?>active<?php endif; ?>"><a href="<?php echo U('special/cart');?>"><i class="fa fa-circle-o"></i> 专题商品包</a></li>
                </ul>
            </li>
            <li class="treeview <?php if(CONTROLLER_NAME == Storesetup or CONTROLLER_NAME == Freight or CONTROLLER_NAME == Delivery or CONTROLLER_NAME == Dlycorp or CONTROLLER_NAME == StoreSetup): ?>active<?php endif; ?>">
                <a href="javascript:;">
                    <i class="fa fa-envelope"></i> <span>店铺配置</span>
                    <span class="pull-right-container">
                        <i class="fa fa-angle-left pull-right"></i>
                    </span>
                </a>
                <ul class="treeview-menu">
                    <li class="<?php if(ACTION_NAME == dlytmp): ?>active<?php endif; ?>"><a href="<?php echo U('freight/dlytmp');?>"><i class="fa fa-circle-o"></i> 快递运费模板</a></li>
                    <li class="<?php if(ACTION_NAME == dlyyctmp): ?>active<?php endif; ?>"><a href="<?php echo U('freight/dlyyctmp');?>"><i class="fa fa-circle-o"></i> 店铺运费模板</a></li>
                    <li class="<?php if(ACTION_NAME == dlycorp): ?>active<?php endif; ?>"><a href="<?php echo U('Dlycorp/dlycorp');?>"><i class="fa fa-circle-o"></i>
                         物流公司</a></li>
                    <li class="<?php if(ACTION_NAME == deliveryInfo): ?>active<?php endif; ?>"><a href="<?php echo U('Delivery/deliveryInfo');?>"><i class="fa fa-circle-o"></i> 发货信息管理</a></li>
                    <li class="<?php if(ACTION_NAME == printer): ?>active<?php endif; ?>"><a href="<?php echo U('Delivery/printer');?>"><i class="fa fa-circle-o"></i> 快递单模板</a></li>
                    <li class="<?php if(CONTROLLER_NAME == Storesetup): ?>active<?php endif; ?>"><a href="<?php echo U('Storesetup/index');?>"><i class="fa fa-circle-o"></i> 店铺基础信息</a></li>
                    <li><a href="<?php echo U('/Admin/StoreDot/index');?>"><i class="fa fa-circle-o"></i> 自提点管理</a></li>
                </ul>
            </li>



            <li class="treeview <?php if(CONTROLLER_NAME == Refund or CONTROLLER_NAME == Feedback): ?>active<?php endif; ?>">
                <a href="javascript:;">
                    <i class="fa fa-folder"></i> <span>售后</span>
                    <span class="pull-right-container">
                      <i class="fa fa-angle-left pull-right"></i>
                    </span>
                </a>
                <ul class="treeview-menu">
                    <li class="<?php if(ACTION_NAME == index): ?>active<?php endif; ?>"><a href="<?php echo U('Refund/index',array('view'=>1));?>"><i class="fa fa-circle-o"></i> 退款退货</a></li>
                    <li><a href="<?php echo U('MemberComplain/index');?>"><i class="fa fa-circle-o"></i> 投诉</a></li>
                </ul>
            </li>
            <li class="treeview <?php if(CONTROLLER_NAME == User or CONTROLLER_NAME == index): ?>active<?php endif; ?>">
                <a href="javascript:;">
                    <i class="fa fa-share"></i> <span>会员</span>
                    <span class="pull-right-container">
                        <i class="fa fa-angle-left pull-right"></i>
                    </span>
                </a>
                <ul class="treeview-menu">
                    <li class="<?php if(ACTION_NAME == index): ?>active<?php endif; ?>"><a href="<?php echo U('User/index');?>"><i class="fa fa-circle-o"></i> 会员列表</a></li>
                    <li class="<?php if(ACTION_NAME == tempUser): ?>active<?php endif; ?>"><a href="<?php echo U('User/tempUser');?>"><i class="fa fa-circle-o"></i> 游客列表</a></li>
                </ul>
            </li>

            <li class="treeview <?php if(CONTROLLER_NAME == StoreOrderSales or CONTROLLER_NAME == StoreGoodsSales or CONTROLLER_NAME == StoreRefund or CONTROLLER_NAME == StoreItemSell or CONTROLLER_NAME == StatisticalLogistics): ?>active<?php endif; ?>">
                <a href="javascript:;">
                    <i class="fa fa-envelope"></i> <span>统计</span>
                    <span class="pull-right-container">
                        <i class="fa fa-angle-left pull-right"></i>
                    </span>
                </a>
                <ul class="treeview-menu">
                    <li class="<?php if(ACTION_NAME == orderSale): ?>active<?php endif; ?>"><a href="<?php echo U('StoreOrderSales/orderSale');?>"><i class="fa fa-circle-o"></i> 订单统计</a></li>

                    <li class="<?php if(ACTION_NAME == StaticalSet): ?>active<?php endif; ?>"><a href="<?php echo U('StatisticalLogistics/StaticalSet');?>"><i class="fa fa-circle-o"></i> 物流统计</a></li>
                    <li class="<?php if(ACTION_NAME == goodsSale): ?>active<?php endif; ?>"><a href="<?php echo U('StoreGoodsSales/goodsSale');?>"><i class="fa fa-circle-o"></i> 商品统计</a></li>
                    <li class="<?php if(ACTION_NAME == index): ?>active<?php endif; ?>"><a href="<?php echo U('StoreRefund/index');?>"><i class="fa fa-circle-o"></i> 退款统计</a></li>

                </ul>
            </li>

            <li class="treeview <?php if(CONTROLLER_NAME == StatisticsUser): ?>active<?php endif; ?>">
                <a href="javascript:;">
                    <i class="fa fa-envelope"></i> <span>会员统计</span>
                    <span class="pull-right-container">
                        <i class="fa fa-angle-left pull-right"></i>
                    </span>
                </a>
                <ul class="treeview-menu">
                    <li class="<?php if(ACTION_NAME == day): ?>active<?php endif; ?>"><a href="<?php echo U('StatisticsUser/day');?>"><i class="fa fa-circle-o"></i> 会员统计(天)</a></li>
                    <li class="<?php if(ACTION_NAME == month): ?>active<?php endif; ?>"><a href="<?php echo U('StatisticsUser/month');?>"><i class="fa fa-circle-o"></i> 会员统计(月)</a></li>
                    <li class="<?php if(ACTION_NAME == newUser): ?>active<?php endif; ?>"><a href="<?php echo U('StatisticsUser/newUser');?>"><i class="fa fa-circle-o"></i> 新增会员统计</a></li>
                </ul>
            </li>
            <li class="treeview <?php if(CONTROLLER_NAME == Distribution or CONTROLLER_NAME == Poster): ?>active<?php endif; ?>">
                <a href="javascript:;">
                    <i class="fa fa-envelope"></i> <span>分销</span>
                    <span class="pull-right-container">
                        <i class="fa fa-angle-left pull-right"></i>
                    </span>
                </a>
                <ul class="treeview-menu">
                    <li class="<?php if(ACTION_NAME == setMoney): ?>active<?php endif; ?>"><a href="<?php echo U('Distribution/setMoney');?>"><i class="fa fa-circle-o"></i> 奖金配置</a></li>
                    <li class="<?php if(ACTION_NAME == memberList): ?>active<?php endif; ?>"><a href="<?php echo U('Distribution/memberList');?>"><i class="fa fa-circle-o"></i> 分销人员列表</a></li>
                    <li class="<?php if(ACTION_NAME == index): ?>active<?php endif; ?>"><a href="/Admin/Poster/index"><i class="fa fa-circle-o"></i> 微信生成海报设置</a></li>
                </ul>
            </li>


            <li class="header">备注</li>
            <li class="treeview <?php if(CONTROLLER_NAME == Bills or CONTROLLER_NAME == index): ?>active<?php endif; ?>">
                <a href="<?php echo U('Bills/index');?>"><i class="fa fa-circle-o text-red"></i> <span>结算账单</span></a>
            </li>
            <li class="treeview <?php if(CONTROLLER_NAME == QgsBills or CONTROLLER_NAME == index): ?>active<?php endif; ?>">
                <a href="<?php echo U('QgsBills/index');?>"><i class="fa fa-circle-o text-red"></i> <span>全国送抽佣账单</span></a>
            </li>
        </ul>
    </section>
    <!-- /.sidebar -->
</aside>

<?php
}elseif(session('userInfo')['type'] == 2){ ?>

<aside class="main-sidebar">
    <section class="sidebar">
        <!-- 导航页面 -->
        <ul class="sidebar-menu">

<?php
 foreach ($nav_menu as $k=>$v) { switch ($k) { case 0: $iClass = 'fa-dashboard'; break; case 1: $iClass = 'fa-th'; break; case 2: $iClass = 'fa-laptop'; break; case 3: $iClass = 'fa-edit'; break; case 4: $iClass = 'fa-table'; break; case 5: $iClass = 'fa-folder'; break; default: $iClass = 'fa-dashboard'; } ?>
            <li class="treeview">
                <a href="#">
                    <i class="fa <?php echo $iClass; ?>"></i> <span><?php echo $v['name'];?></span>
                    <span class="pull-right-container">
              <i class="fa fa-angle-left pull-right"></i>
            </span>
                </a>
                <ul class="treeview-menu">
                    <?php
 foreach ($menu as $value) { if($v['id'] == $value['nav_menu_id']) { ?>
                    <li><a href="<?php echo $value['value']; ?>"><i class="fa fa-circle-o"></i> <?php echo $value['name']?></a></li>
                    <?php }} ?>
                </ul>
            </li>
<?php } ?>
        </ul>
        <script type="text/javascript">
			var curHref = window.location.href.toLowerCase();
			$(".sidebar-menu .treeview-menu a").each(function(){
				if(curHref.indexOf($(this).attr("href").toLowerCase()) != -1){
					$(this).parents(".treeview").addClass("active");
					$(this).parent().addClass("active");
				}	
			});
		</script>
    </section>
    <!-- /.sidebar -->
</aside>
<?php } ?>
<style type="text/css">
.goods-table-view{width:100%;overflow:auto;}
.goods-table-view th{white-space:nowrap;}
</style>
<!-- 内容页 -->
<div class="content-wrapper">
    <!-- 面包屑 -->
    <section class="content-header">
        <h1>
            商品
            <small>管理</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 商品管理</a></li>
            <li class="active">上架商品配置</li>
        </ol>
    </section>
    <!-- 内容 -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box" style="overflow-x: scroll">
                    <div class="box-header">
                        <h3 class="box-title"></h3>


                        <div class="form-inline pull-right">
                            <form action="/admin/StoreGoods/index" method="get">
                                <fieldset>
                   <!--                 <div class="input-group input-group-sm">
                                        <select class="form-control valid" name="store_status" style="height: 30px; font-size: 12px;" aria-invalid="false">
                                            <option value="">请选择上、下架</option>
                                            <option value="true" <?php echo $_GET['store_status'] == 'true' ? 'selected="selected"' : '' ;?> >上架</option>
                                            <option value="false" <?php echo $_GET['store_status'] == 'false' ? 'selected="selected"' : '' ;?> >下架</option>
                                        </select>
                                    </div>-->
                                    <div class="input-group input-group-sm">
                                        <span class="input-group-addon"><strong>货品条码</strong></span>
                                        <input type="text" class="form-control" placeholder="货品条码" name="barcode" value="<?php echo ($barcode); ?>">
                                    </div>
                                    <div class="input-group input-group-sm">
                                        <span class="input-group-addon"><strong>货品名称</strong></span>
                                        <input type="text" class="form-control" placeholder="货品名称" name="name" value="<?php echo ($name); ?>">
                                    </div>
                                    <div class="input-group input-group-sm">
                                        <div class="input-group-btn">
                                            <button type="submit" class="btn btn-primary"><i class="fa fa-search"></i>
                                            </button>
                                        </div>
                                    </div>
                                </fieldset>
                            </form>
                        </div>
                    </div>
                    <!-- /.box-header -->
                    <div class="box-body table-responsive no-padding" style="height:480px;overflow:auto;">
                        <table class="table table-hover goods-table-view">
                            <tbody>
                            <tr>
                                <th><input type="checkbox" class="grid-select-all"></th>
                                <th>货品ID</th>
                                <th>条码</th>
                                <th>货品名称</th>
                                <th>活动中</th>
                                <th>图片</th>
                                <th>指导价</th>
                                <th>货品描述</th>
                                <th>
                                    <div class="btn btn-sm btn-success"><i class="fa fa-save"></i>&nbsp;&nbsp;标签</div>
                                </th>
                                <th>店铺市场价</th>
                                <th>店铺销售价</th>
                                <th>店铺库存</th>
                                <th>货号</th>
                                <th>是否快递</th>
                                <th>冻结库存</th>
                                <th>商品分类</th>
                                <th>特别说明</th>
                            </tr>
                            <?php if(is_array($product_relation_msg)): foreach($product_relation_msg as $key=>$v): ?><tr class="cg-product-tr yc-srarea">
                                    <?php if($v['store_status'] == 'true'): ?><td><input type="checkbox" class="grid-item" data-id="<?php echo ($v["product_id"]); ?>" checked>
                                        </td>
                                        <?php else: ?>
                                        <td><input type="checkbox" class="grid-item" data-id="<?php echo ($v["product_id"]); ?>"></td><?php endif; ?>
                                    <td><?php echo ($v["product_id"]); ?></td>
                                    <td><?php echo ($v["barcode"]); ?></td>
                                    <td><?php echo ($v["name"]); ?></td>
                                    <td>
                                        <?php
 if (goods_is_Order_promotion($v['store_pid'], $v['local_id'])) { echo '<span class="badge bg-green">订单促销</span>'; } if (goods_is_Goods_promotion($v['store_pid'], $v['local_id'])) { echo '<span class="badge bg-green">商品促销</span>'; } if (goods_is_shangou($v['store_pid'], $v['local_id'])) { echo '<span class="badge bg-green">闪购</span>'; } if (checkProductIsGroupPromotion($v['store_pid'], $v['local_id'])) { echo '<span class="badge bg-green">组合促销</span>'; } if (checkProductIsSpecial($v['store_pid'], $v['local_id'])) { echo '<span class="badge bg-green">专题商品包</span>'; } ?>
                                    </td>
                                    <td><img class="scale-img" src="<?php echo getThumb($v['goods_id']);?>" data-bimg="<?php echo getThumb($v['goods_id']);?>"/></td>
                                    <td><span class="badge bg-green"><?php echo ($v["guidance_price"]); ?></span></td>
                                    <td><?php echo ($v["spec_info"]); ?></td>
                                    <td><a href="#" class="btn btn-sm btn-success labels" id="<?php echo ($v["product_id"]); ?>"><i
                                            class="fa fa-save"></i>&nbsp;&nbsp;标签</a></td>

                                    <?php $marketprice = get_store_product($v['product_id'], 'marketprice') ?>
                                    <td><input type="text" class="form-control grid-mktprice" name="mktprice" value="<?php echo ($marketprice); ?>" style="width:100px;height:30px;"></td>
                                    <?php $price = get_store_product($v['product_id'], 'price') ?>
                                    <td><input type="text" class="form-control grid-price" name="price" value="<?php echo ($price); ?>" style="width:100px;height:30px;"></td>
                                    <?php $store = get_store_product($v['product_id'], 'store') ?>
                                    <?php $freez = get_store_product($v['product_id'], 'freez') ?>
                                    <td><input type="text" class="form-control grid-store" name="store" data-min="<?php echo ($freez); ?>" value="<?php echo ($store); ?>" style="width:100px;height:30px;"></td>
                                    <!--<?php $discount = get_store_product($v['product_id'], 'discount') ?>-->
                                    <!--<td><input type="text" class="form-control grid-discount" name="discount"-->
                                    <!--value="<?php if(!empty($discount)): echo ($discount); else: echo ($v["discount"]); endif; ?>" style="width: 100px;height: 30px;"></td>-->
                                    <?php $bn = get_store_product($v['product_id'], 'bn') ?>
                                    <td><input type="text" class="form-control grid-bn" name="bn" value="<?php echo ($bn); ?>" style="width:100px;height:30px;"></td>
                                    <?php $is_transport = get_store_product($v['product_id'], 'is_transport') ?>
                                    <td>
                                        <select name="is_transport" class="form-control grid-transport"style="min-width:62px" >
                                            <option value="true" <?php if($is_transport == 'true'): ?>selected<?php endif; ?>>是</option>
                                            <option value="false" <?php if($is_transport == 'false'): ?>selected<?php endif; ?>>否</option>
                                        </select>
                                    </td>                                    
                                    <td><?php echo ($freez); ?></td>
                                    <td>
                                        <select class="form-control grid-cat" style="min-width:100px;">
                                            <option value="">请选择</option>
                                            <?php
 $goods_cat = get_store_product($v['product_id'], 'scate_id'); foreach($parent as $p){ ?>
                                            <option disabled="disabled"
                                            <?php echo ($p['store_cat_id'] == $goods_cat) ? 'selected' : ''; ?>
                                            value="<?php echo $p['store_cat_id'];?>"><?php echo $p['cat_name'];?></option>

                                            <?php foreach($second as $s){ if ($s['parent_id'] == $p['store_cat_id']) { ?>


                                            <option
                                            <?php echo ($s['store_cat_id'] == $goods_cat) ? 'selected' : ''; ?>
                                            value="<?php echo $s['store_cat_id'];?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $s['cat_name'];?></option>
                                            <?php foreach($three as $t){ if ($t['parent_id'] == $s['store_cat_id']) { ?>
                                            <option
                                            <?php echo ($t['store_cat_id'] == $goods_cat) ? 'selected' : ''; ?>
                                            value="<?php echo $t['store_cat_id'];?>">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $t['cat_name'];?></option>

                                            <?php }} ?>

                                            <?php }} ?>
                                            <?php } ?>
                                        </select>
                                    </td>
                                    <td><input type="text" name="explain" value="<?php echo ($v["explain"]); ?>" class="form-control grid-explain" style="width:120px;"></td>
                                </tr>
                                <tr class="yc-validation">
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td><span class="valid-mktprice"></span></td>
                                    <td><span class="valid-price"></span></td>
                                    <td><span class="valid-store"></span></td>
                                    <td><span class="valid-bn"></span></td>
                                    <td>&nbsp;</td>
                                    <td></td>
                                    <td><span class="valid-cat"></span></td>
                                    <td>&nbsp;</td>
                                </tr><?php endforeach; endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        <input type="checkbox" class="grid-select-all">&nbsp;&nbsp;&nbsp;
                        <a class="btn btn-sm btn-info add-goods">保存</a>
                        <?php echo ($show); ?>
                    </div>
                    <!-- /.box-body -->
                </div>
            </div>
        </div>
    </section>
</div>
<!-- 底部 -->
<footer class="main-footer">
    <div class="pull-right hidden-xs">
        <b>Version</b> 3.0
    </div>
    <strong>Copyright &copy; 2016-2018 <a href="#">怡臣</a>.</strong> All rights
    reserved.
</footer>
</div>
<!-- Bootstrap 3.3.6 -->
<script src="/Public/admin/adminlte/bootstrap/js/bootstrap.min.js"></script>
<!-- AdminLTE App -->
<script src="/Public/admin/adminlte/dist/js/app.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="/Public/admin/adminlte/dist/js/demo.js"></script>
<script src="/Public/admin/adminlte/plugins/iCheck/icheck.min.js"></script>
<script type="text/javascript">
    $('.grid-refresh').click(function () {
        window.location.reload();
    });
    $('.gobackpage').click(function () {
        window.history.back();
    })
</script>
</body>
</html>
<script src="/Public/layer/layer.js"></script>
<script type="text/javascript">	
	var yc_srareaArr = [];
	var yc_validateArr = [];
	var yc_choseArr = [];
	var _isAjaxSave = false;
	$(".yc-srarea").each(function(){
		yc_srareaArr.push($(this));
		yc_choseArr.push(true);
	});
	$(".yc-validation").each(function(){
		yc_validateArr.push($(this));
	});
	// 检查保存数据
	function checkSaveDatas(){				
		$(".grid-item").each(function(i, o){
			if($(o).prop("checked")){
				yc_choseArr[i] = true;
			}else{
				yc_choseArr[i] = false;
			}			
		});		
		$(".grid-mktprice").each(function(i, o){
			var v = $(o).val();
			var cur = yc_validateArr[i].find(".valid-mktprice");
			cur.removeClass("error");
			if(yc_choseArr[i]){
				if(mbValidator.isEmpty(v)){
					//市场价格为空可以通过验证
					cur.html("");
					//cur.addClass("error").html("请输入店铺市场价");
				}else if(!mbValidator.isGoodsPrice(v)){
					cur.addClass("error").html("请输入大于0的数字");
				}else{
					mbValidator.fixPrice(o, v);
					cur.html("");
				}
			}
		});
		$(".grid-price").each(function(i, o){
			var v = $(o).val();
			var cur = yc_validateArr[i].find(".valid-price");
			cur.removeClass("error");
			if(yc_choseArr[i]){
				if(mbValidator.isEmpty(v)){
					cur.addClass("error").html("请输入店铺销售价");
				}else if(!mbValidator.isGoodsPrice(v)){
					cur.addClass("error").html("请输入大于0的数字");
				}else{
					mbValidator.fixPrice(o, v);
					cur.html("");
				}	
			}
			
		});
		$(".grid-store").each(function(i, o){
			var v = $(o).val();
			var cur = yc_validateArr[i].find(".valid-store");
			cur.removeClass("error");
			if(yc_choseArr[i]){
				if(mbValidator.isEmpty(v)){
					cur.addClass("error").html("请输入店铺库存");
				}else if(!mbValidator.isPositiveInt(v)){
					cur.addClass("error").html("店铺库存数量必须是大于0的整数");
				}else if(parseInt(v) < parseInt($(o).data("min"))){
					cur.addClass("error").html("店铺库存数量要大于冻结库存数量"+$(o).data("min"));
				}else{
					cur.html("");
				}
			}
		});
		$(".grid-bn").each(function(i, o){
			var v = $(o).val();
			var cur = yc_validateArr[i].find(".valid-bn");
			cur.removeClass("error");
			if(yc_choseArr[i]){
				if(mbValidator.isEmpty(v)){
					cur.addClass("error").html("请输入货号");
				}else{
					$(o).val(v.trim());
					cur.html("");
				}
			}			
		});
		$(".grid-cat").each(function(i, o){
			var v = $(o).val();
			var cur = yc_validateArr[i].find(".valid-cat");
			cur.removeClass("error");
			if(yc_choseArr[i]){
				if(mbValidator.isEmpty(v)){
					cur.addClass("error").html("请选择商品分类");
				}else{
					cur.html("");
				}
			}			
		});
	}
    $(function () {
		showBigPicture();
        $('.grid-select-all').change(function () {
            if (this.checked) {
                $('.grid-item').prop("checked", true);
            } else {
                $('.grid-item').prop("checked", false);
            }
        });
        $('.add-goods').on('click', function () {
			if(_isAjaxSave) return;
			_isAjaxSave = true; 	
			checkSaveDatas();
			if($(".error").length > 0){
				_isAjaxSave = false;
				alert("有错误数据，请根据提示修改后再保存！");
				return;
			}
            var selected = [];

            $('.grid-item').each(function (i, o) {
                var id = $(this).data('id');
                var mktprice = yc_srareaArr[i].find('.grid-mktprice').val();
                var price = yc_srareaArr[i].find('.grid-price').val();
                var store = yc_srareaArr[i].find('.grid-store').val();
//              var discount = $(this).parent().nextAll().find('.grid-discount').val();
                var discount = '';
                var cat = yc_srareaArr[i].find('.grid-cat').val();
                var bn = yc_srareaArr[i].find('.grid-bn').val();
                var transport = yc_srareaArr[i].find('.grid-transport').val();
                var explain = yc_srareaArr[i].find('.grid-explain').val();
                bn = encodeURIComponent(bn);
                if ($(this).is(':checked')) {
                    var goods_values = id + '#' + mktprice + '#' + price + '#' + store + '#' + discount + '#1' + '#' + cat + '#' + bn + '#' + transport + '#' + explain;
                    selected.push(goods_values);
                } else {
                    var goods_values = id + '#' + mktprice + '#' + price + '#' + store + '#' + discount + '#0' + '#' + cat + '#' + bn + '#' + transport + '#' + explain;
                    selected.push(goods_values);
                }
            });

            if (selected.length == 0) {
				_isAjaxSave = false;
                return;
            }
			GPopup.loadDialog();
			 $.post('/admin/StoreGoods/addGoods/', {data: selected}, function (data) {
				 GPopup.removeLoad();
				 _isAjaxSave = false;
                 data = eval("("+data+")");
                 GPopup.alertTip(data.msg);
//				 if(data == 1) {
//					GPopup.alertTip('保存成功！');
//					setTimeout(function(){window.location.reload();}, 2000);
//				}else{
//					GPopup.alertTip('保存失败！');
//				}
            });
        });

        $('.labels').click(function () {
            var id = $(this).attr('id');
            layer.ready(function () {
                layer.open({
                    type: 2,
                    title: '标签',
                    fix: false,
                    maxmin: true,
                    shadeClose: true,
                    area: ['600px', '500px'],
                    content: "/admin/storeGoods/label/id/" + id,
                    end: function () {
                        layer.tips('Hi', '#about', {tips: 1})
                    }
                });
            });
        })
    });
</script>